﻿
// **************************************************************************
//    Class Created by Mick Doherty (Dotnetrix) May 2010
//    http://dotnetrix.co.uk/
//
//    ...for GlassUI (an AeroGlass UI Library)
//    http://glassui.codeplex.com/
// **************************************************************************

using System;
using System.ComponentModel;
using System.Drawing;
using System.Reflection;

namespace GlassUI
{
    // Class wil be used in the future so as to store bounds information
    // rather than calculate every time a paint is performed.
    public class TextImageLayout
    {
        public TextImageLayout(Component owner)
        {
            this.Owner = owner;
        }

        private Component Owner;
        private Rectangle contentBounds = Rectangle.Empty;
        private Rectangle imageBounds = Rectangle.Empty;
        private Rectangle textBounds = Rectangle.Empty;

        private Rectangle ContentRectangle
        {
            get { return contentBounds; }
        }

        public Rectangle ImageRectangle
        {
            get { return imageBounds; }
        }

        public Rectangle TextRectangle
        {
            get { return textBounds; }
        }

        public void CalculateLayout(Rectangle bounds)
        {
            contentBounds = bounds;
            Image image = ReflectedImage();
            String text = ReflectedText();

            Size imageSize = image == null ? Size.Empty : image.Size;
            Size textSize = Size.Empty;
        }

        public Size GetPreferredSize(Size proposedSize)
        {
            return Size.Empty;
        }

        internal Image ReflectedImage()
        {
            PropertyInfo info = this.Owner.GetType().GetProperty("Image");
            if (info != null)
                return (Image)info.GetValue(this.Owner, null);
            return null;
        }

        internal string ReflectedText()
        {
            PropertyInfo info = this.Owner.GetType().GetProperty("Text");
            if (info != null)
                return (string)info.GetValue(this.Owner, null);
            return string.Empty;
        }

    }
}
